package com.shi.vueblog.common.result;

import lombok.Data;
import java.io.Serializable;

/**
 * 返回结果统一处理
 */
@Data
public class Result implements Serializable {
    private int code;
    private String msg;
    private Object data;

    public static Result succ(Object data){
        Result m=new Result();
        m.setCode(200);
        m.setMsg("成功");
        m.setData(data);
        return m;
    }

    public static  Result succ(String msg , Object data){
        Result m=new Result();
        m.setCode(200);
        m.setMsg(msg);
        m.setData(data);
        return m;
    }
    public static Result fail(String msg){
        Result m=new Result();
        m.setCode(-1);
        m.setMsg(msg);
        m.setData(null);
        return m;
    }
    public static  Result fail(String msg,Object data){
        Result m=new Result();
        m.setCode(-1);
        m.setMsg(msg);
        m.setData(data);
        return m;
    }
    public static  Result fail(int code,String msg,Object data){
        Result m=new Result();
        m.setCode(code);
        m.setMsg(msg);
        m.setData(data);
        return m;

    }


}
